package com.cap7.config;

import com.cap1.Person;
import com.cap7.bean.Bike;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@ComponentScan("com.cap7.bean")
@Configuration
public class Cap7MainConfigOfLifeCycle {
    //容器启动时初始化的Bean
    @Bean("person")
    public Person person() {
        System.out.println("给容器中添加----person----");
        return new Person("james", 20);
    }
    //@Scope("prototype")
    @Bean(initMethod = "init" ,destroyMethod = "destory")//指定初始化方法和销毁方法
    public Bike bike() {
        return new Bike();
    }
}
